package com.wyj;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author ：wyj
 * @description：TODO
 * @date ：2023/2/8 10:08 下午
 */
@SpringBootTest
public class JsonTexts {

    @Test
    void text01() {
        List<Map<String,Object>> addScoreList = new ArrayList<>();

        //3个link2
        for (int i = 0; i < 3; i++) {
            Map<String, Object> everyMap = new HashMap<>();
            everyMap.put("link2Pos",i);
            List<collectMap> collectList = new ArrayList<>();
            //6个link1
            for (int j = 0; j < 6; j++) {
                collectMap collectMap = new collectMap();
                collectMap.setPos(i);
                collectMap.setPreScore(100L);
                collectMap.setCurScore(1000L);
                collectMap.setAddScore(900L);
                collectMap.setPreSymbolType(97);
                collectMap.setCurSymbolType(98);
                collectList.add(collectMap);
            }
            everyMap.put("collectList",collectList);
            everyMap.put("everyLink2WinCount",999);

            addScoreList.add(everyMap);
        }

        Map<String, Object> map = new HashMap<>();
        map.put("addScoreList",addScoreList);
        String s = JSON.toJSONString(map);

        JSONObject jsonObject = JSON.parseObject(s);

        Object addScoreList1 = jsonObject.get("addScoreList");
        System.out.println(addScoreList1);


    }

    class collectMap {
        private Integer pos;
        private Long preScore;
        private Long curScore;
        private Long addScore;
        private Integer preSymbolType;
        private Integer curSymbolType;

        public collectMap(){}
        public collectMap(Integer pos, Long preScore, Long curScore, Long addScore, Integer preSymbolType, Integer curSymbolType) {
            this.pos = pos;
            this.preScore = preScore;
            this.curScore = curScore;
            this.addScore = addScore;
            this.preSymbolType = preSymbolType;
            this.curSymbolType = curSymbolType;
        }

        public Integer getPos() {
            return pos;
        }

        public void setPos(Integer pos) {
            this.pos = pos;
        }

        public Long getPreScore() {
            return preScore;
        }

        public void setPreScore(Long preScore) {
            this.preScore = preScore;
        }

        public Long getCurScore() {
            return curScore;
        }

        public void setCurScore(Long curScore) {
            this.curScore = curScore;
        }

        public Long getAddScore() {
            return addScore;
        }

        public void setAddScore(Long addScore) {
            this.addScore = addScore;
        }

        public Integer getPreSymbolType() {
            return preSymbolType;
        }

        public void setPreSymbolType(Integer preSymbolType) {
            this.preSymbolType = preSymbolType;
        }

        public Integer getCurSymbolType() {
            return curSymbolType;
        }

        public void setCurSymbolType(Integer curSymbolType) {
            this.curSymbolType = curSymbolType;
        }
    }

}
